package com.ljj.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.ljj.entity.Carousel;
import com.ljj.mapper.CarouselMapper;
import com.ljj.utli.Result;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author liujiju
 * @since 2021-11-19
 */
@CrossOrigin
@RestController
@RequestMapping("/carousel")
public class CarouselController {

	@Autowired
	CarouselMapper cm;

	@RequestMapping("/amlist")
	public Object amlist(Carousel c) {
		

		List<Carousel> list = cm.clist(c);
		
		return  list;

	}

	@RequestMapping("/amadd")
	public Object amadd(Carousel c) {

		if (cm.insert(c) > 0) {
			return new Result(0, "添加成功");
		} else {
			return new Result(0, "添加失败");
		}
	}
	
	@RequestMapping("/amupdate")
	public Object amupdate(Carousel c) {

		if (cm.updateById(c)>0) {
			return new Result(0, "修改成功");
		} else {
			return new Result(0, "修改失败");
		}
	}

	@RequestMapping("/amdelete")
	public Object amdelete(Carousel c) {

		if (cm.deleteById(c) > 0) {
			return new Result(0, "删除成功");
		} else {
			return new Result(0, "删除失败");
		}

	}

}
